package com.cuit.service;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.cuit.mapper.UsersMapper;
import com.cuit.pojo.Users;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class ThreadMethod {

    @Async("taskExecutor")
    public void updateLoginIPAndTime(UsersMapper usersMapper, String ipAddr, Users users) {
        LambdaUpdateWrapper<Users> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(Users::getUserId,users.getUserId());
        updateWrapper.set(Users::getLastTimeIp,ipAddr);
        updateWrapper.set(Users::getLastLoginTime,new Date());
        usersMapper.update(null,updateWrapper);
    }
}
